package com.smartwebx.ha.web.gis.module.screen;

import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLEncoder;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.google.common.base.Splitter;

public class GridExportCsv extends BasicScreen {
	@Autowired
	private HttpServletResponse response;

	public void export(String csvDatas) throws IOException {
		response.setHeader("Content-Type", "application/csv;charset=gb18030");
		response.setHeader("Content-Disposition", "attachment;filename="
				+ URLEncoder.encode("下载", "UTF-8") + ".csv");

		PrintWriter out = response.getWriter();
		Iterable<String> csvDataList = Splitter.on("||").split(csvDatas);

		for (String csvLine : csvDataList) {
			out.println(csvLine);
		}
		out.flush();
		out.close();
	}
}